<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>订单列表</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/driver.js"></script>
    <script src="../../js/common.js"></script>
</head>
<body>
<section id="order_list_section">
    <section class="itemgroup mt10">
        <div class="order_title" id="waybillNum">
            订单编号: JJ1609120001<label class="type ml5">APP</label>
            <label class="right gray">明日 15:30</label>
        </div>
        <div class="photoitem ml15 font14">
            <i class="iconfont mr5 green icon20">&#xe70d;</i>
            共和新路3288弄3号
        </div>
        <div class="photoitem ml15 font14">
            <i class="iconfont mr5 red icon20">&#xe70c;</i>
            共和新路3288弄3号
        </div>
        <div class="oneitem p15">
            <label class="gray font12">特殊要求:</label>
            <div class="comments_type right">备注</div>
            <div class="comments_type right mr5">搬运</div>
            <div class="comments_type right mr5">回单</div>
        </div>
        <div class="orderitem p15 lh40 font14">
            费用:<label class="red">￥129</label>
            <button class="btn right orderbtn"></button>
        </div>
    </section>
</section>
<script type="text/javascript">
    $(function () {
        //token验证
        checkDriverToken();
    });
    $(document).ready(function () {
        var url = _global.serverHost + "/driver/order_list.htm";
        var data = {driverUuid: getCookie("driverUuid")};
        _callAjaxRequest(url, data, orderBack);

        function orderBack(data) {
            var bidList = data.bidList;
            var order_list_section = "";
            if (bidList.length <= 0) {
                order_list_section = '<section class="itemgroup mt10" style="text-align: center">没有更多的抢单信息</section>';
            } else {
                for (var i = 0; i < bidList.length; i++) {
                    var waybillSource = "";
                    if (bidList[i].waybillSource == '10') {
                        waybillSource = "<label class='type ml5'>APP</label>";
                    } else if (bidList[i].waybillSource == '20') {
                        waybillSource = "<label class='type ml5'>网站</label>";
                    } else if (bidList[i].waybillSource == '30') {
                        waybillSource = "<label class='type ml5'>客服电话</label>";
                    }
                    var require = "";
                    if (bidList[i].requireList.length > 0) {
                        require = '<div class="oneitem p15">'
                                + '<label class="gray font12">特殊要求:</label>';
                        for (var j = 0; j < bidList[i].requireList.length; j++) {
                            require = require + '<div class="comments_type right';
                            if (j > 0) {
                                require = require + ' mr5';
                            }
                            require = require + '">' + bidList[i].requireList[j].requirementName + '</div>';
                        }
                        require = require + '</div>';
                    }
                    var order_status = "";
                    if (bidList[i].status == '90') {
                        order_status = "订单完成";
                    } else if (bidList[i].status == '70') {
                        order_status = "等待评价";
                    } else {
                        order_status = "进行中";
                    }

                    order_list_section = order_list_section + '<section class="itemgroup mt10" onclick="goOrderDetail(\'' + bidList[i].waybillId + '\')">' +
                            '<div class="order_title">'
                            + '订单编号: ' + bidList[i].waybillNum
                            + waybillSource + '<label class="right gray">' + bidList[i].bookDateDesc + '</label>'
                            + '</div>'
                            + '<div class="photoitem ml15 font14">'
                            + '<i class="iconfont mr5 green icon20">&#xe70d;</i>'
                            + bidList[i].startAddr
                            + '</div>'
                            + '<div class="photoitem ml15 font14">'
                            + '<i class="iconfont mr5 red icon20">&#xe70c;</i>'
                            + bidList[i].endAddr
                            + '</div>'
                            + require
                            + '<div class="orderitem p15 lh40 font14">'
                            + '费用:<label class="red">￥' + bidList[i].planTotalFee + '</label>'
                            + '<button type="button" class="btn right orderbtn"> '
                            + order_status
                            + '</button>'
                            + '</div></section>';
                }
            }
            $("#order_list_section").html(order_list_section);
        }
    });
    function goOrderDetail(waybillId) {
        var url = _global.serverHost + "/driver/go_by_status.htm";
        var data = {waybillId: waybillId};
        _callAjaxRequest(url, data, goOrderDetailBack);
    }

    function goOrderDetailBack(data) {
        if (data.waybill.status == '30') {
            window.location.href = "../start_bid/start_bid.html?waybillId=" + data.waybill.waybillId;
        } else if (data.waybill.status == '35') {
            window.location.href = "../start_bid/goon_bid1.html?waybillId=" + data.waybill.waybillId;
        } else if (data.waybill.status == '40') {
            window.location.href = "../start_bid/goon_bid2.html?waybillId=" + data.waybill.waybillId;
        } else if (data.waybill.status == '50') {
            window.location.href = "../start_bid/goon_bid3.html?waybillId=" + data.waybill.waybillId;
        } else if (data.waybill.status == '55') {
            window.location.href = "../start_bid/goon_bid4.html?waybillId=" + data.waybill.waybillId;
        } else if (data.waybill.status == '60') {
            window.location.href = "../start_bid/goon_bid5.html?waybillId=" + data.waybill.waybillId;
        } else if (data.waybill.status == '70') {
            window.location.href = "../start_bid/ok_bid.html?waybillId=" + data.waybill.waybillId;
        } else {
            window.location.href = "../start_bid/ok_bid.html?waybillId=" + data.waybill.waybillId;
        }
    }
</script>
</body>
</html>